package com.bawei.module_live.repository

import com.bawei.lib_net.RetrofitFactory
import com.bawei.module_live.version1.GoodsApi
import com.bawei.module_live.version1.VideoApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

class LiveRepository {
    val api: VideoApi
    val goodsApi: GoodsApi
    
    init {
        api = RetrofitFactory.getRetrofitFactory().create(VideoApi::class.java)
        goodsApi = RetrofitFactory.getRetrofitFactory().create(GoodsApi::class.java)
    }
    
    /**
     * 获取推荐视频信息
     */
    suspend fun getVideo(page: Int, pageSize: Int) = flow {
        emit(api.getVideo(page, pageSize))
    }.flowOn(Dispatchers.IO)

    /**
     * 获取商品列表
     */
    suspend fun getGoodsList(categoryId: Int, currentPage: Int, pageSize: Int, roomId: Int) = flow {
        emit(goodsApi.getGoodsList(categoryId, currentPage, pageSize, roomId))
    }.flowOn(Dispatchers.IO)
} 